/*
 * @Author: Y先森
 * @Date: 2023-05-03 15:32:17
 * @LastEditors: y && 250048395@qq.com
 * @LastEditTime: 2023-05-03 15:45:23
 * @FilePath: \y-website\config\pageConfig.js
 */
import chalk from 'chalk'

// 引入多页面配置文件
const project = require('../scripts/multiPages.json')
// 获取npm run dev后缀 配置的环境变量
export const npm_config_page = process.env.npm_config_page || ''
// 命令行报错提示
const errorLog = (error) => console.log(chalk.red(`${error}`))

//获取指定的单页面入口
export const getEnterPages = (path) => {
  if (!npm_config_page)
    errorLog(
      '--------------请在命令行后以 `--page=页面名称` 格式指定页面名称！---------------'
    )
    console.log('npm_config_page=>',npm_config_page)    
  const filterArr = project.filter(
    (item) => item.chunk.toLowerCase() == npm_config_page.toLowerCase()
  )
  if (!filterArr.length)
    errorLog(
      '-----------------------不存在此页面，请检查页面名称！-------------------------'
    )
  console.log('npm_config_page=>>',npm_config_page)
  return {
    [npm_config_page]: path.resolve(
      __dirname,
      `src/Project/${npm_config_page}/index.html`
    )
  }
}
  